﻿Imports System
Imports System.ComponentModel.Design.Serialization
Imports System.Workflow.ComponentModel.Design

Namespace System.Workflow.ComponentModel.Serialization
    Friend NotInheritable Class PropertySegmentSerializationProvider
        Inherits WorkflowMarkupSerializationProvider
        ' Methods
        Public Overrides Function GetSerializer(ByVal manager As IDesignerSerializationManager, ByVal currentSerializer As Object, ByVal objectType As Type, ByVal serializerType As Type) As Object
            If Not serializerType.IsAssignableFrom(GetType(WorkflowMarkupSerializer)) Then
                Return MyBase.GetSerializer(manager, currentSerializer, objectType, serializerType)
            End If
            If TypeOf currentSerializer Is PropertySegmentSerializer Then
                Return currentSerializer
            End If
            If (objectType Is GetType(PropertySegment)) Then
                Return New PropertySegmentSerializer(Nothing)
            End If
            If TypeOf currentSerializer Is WorkflowMarkupSerializer Then
                Return New PropertySegmentSerializer([TryCast](currentSerializer,WorkflowMarkupSerializer))
            End If
            Return Nothing
        End Function

    End Class
End Namespace

